package org.pearl.spring.demo.spel;

import org.pearl.spring.demo.pojo.Animal;
import org.pearl.spring.demo.spel.Security.SecurityExpressionRoot;
import org.pearl.spring.demo.spel.Security.WebSecurityExpressionRoot;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;

/**
 * Created by TD on 2021/8/6
 */
public class SecurityTest {
    public static void main(String[] args) {

        // 1.创建一个表达式解析器
        ExpressionParser parser = new SpelExpressionParser();

        StandardEvaluationContext context = new StandardEvaluationContext();
        WebSecurityExpressionRoot securityExpressionRoot = new WebSecurityExpressionRoot(null,null);
        context.setRootObject(securityExpressionRoot); // 设置根对象
        String value = (String) parser.parseExpression("has()").getValue(context);


        System.out.println(value);


    }
}
